package com.boe.csb.web.controller.base;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.boe.csb.core.common.exception.CSBErrorCode;
import com.boe.csb.core.entity.SimplePageInfo;
import com.boe.csb.core.service.user.BoeCloudLogService;
import com.boe.csb.web.controller.BaseController;
import com.boe.csb.web.model.ResultModel;

/**
 * @author xinghe
 * @date 2017 - 05 - 02 下午14:43
 */
@RestController
@RequestMapping("/api/log/")
public class CloudLogController extends BaseController {
    @Autowired
    private BoeCloudLogService boeCloudLogService;
    

    @SuppressWarnings("rawtypes")
	@RequestMapping(value = "queryErrorLog")
    public ResultModel<SimplePageInfo> queryErrorLog(@RequestParam String startTime,@RequestParam String endTime,@RequestParam Integer limit,@RequestParam Integer pageNum) {
    	SimplePageInfo sim = boeCloudLogService.queryCloudErrorLog(startTime, endTime,limit,pageNum);
    	if(sim == null){
    		return ResultModel.fail(CSBErrorCode.SYS_EXP, "错误日志查询失败！");
    	}
    	return ResultModel.success(sim);
    }
    
    @SuppressWarnings("rawtypes")
	@RequestMapping(value = "queryStatisticsLog")
    public ResultModel<SimplePageInfo> queryStatisticsLog(@RequestParam String startTime,@RequestParam String endTime,@RequestParam String apiName,@RequestParam String apiRelease,@RequestParam String apiCaller,@RequestParam Integer limit,@RequestParam Integer pageNum,@RequestParam Integer flag){
    	SimplePageInfo sim = boeCloudLogService.queryStatisticsLog(startTime, endTime,apiName,apiRelease,apiCaller,limit,pageNum,flag);
    	if(sim == null){
    		return ResultModel.fail(CSBErrorCode.SYS_EXP, "统计日志查询失败！");
    	}
    	return ResultModel.success(sim);
    }

}
